//
//  BrandViewController.m
//  HomePage
//
//  Created by HanHaiDi on 13-8-22.
//  Copyright (c) 2013年 winston. All rights reserved.
//

#import "BrandViewController.h"
#import "BrandDetailViewController.h"

@interface BrandViewController ()

@end

@implementation BrandViewController

-(id)initWithFrame:(CGRect)frame
{
    self = [super init];
    if (self) {
        self.view.frame = frame;
        [self.view setBackgroundColor:[UIColor whiteColor]];
        
        UIImageView * background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,1024, 768)];
        [self.view addSubview:background];
        [background release];
        [background setImage:[UIImage imageNamed:@"AllAuto_Image_BG"]];
        
        UIButton *  backBtn = [[UIButton alloc]initWithFrame:CGRectMake(50, 18, 55,40)];
        [backBtn setImage:[UIImage imageNamed:@"home_button"] forState:UIControlStateNormal];
        [backBtn addTarget:self action:@selector(onBack:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:backBtn];
        [backBtn release];
        
        UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(160, 25, 400, 35)];
        titleLabel.backgroundColor = [UIColor clearColor];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.font = [UIFont fontWithName:@"Arial" size:30];
        titleLabel.textColor = [UIColor colorWithRed:0.4 green:0.4 blue:0.4 alpha:1.0];
        [self.view addSubview:titleLabel];
        [titleLabel release];
        [titleLabel setText:@"品牌故事"];
        
        UIImageView * lineView = [[UIImageView alloc] initWithFrame:CGRectMake((frame.size.width-658)/2,70, 658, 8)];
        lineView.image = [UIImage imageNamed:@"AllAuto_Config_TimeLine_BG"];
        [self.view addSubview:lineView];
        [lineView release];
        
                
        
        brandview = [[BrandView alloc] initWithFrame:CGRectMake(0, 110, frame.size.width, frame.size.height-110)];
        [self.view addSubview:brandview];
        [brandview release];
        
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(onGoBrandPage:) name:Notification_Navigate_To_Brand object:nil];

    }
    return self;
}

-(void)onBack:(id)sender
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(void)onGoBrandPage:(NSNotification*)notify
{
    NSDictionary * dic = (NSDictionary *)[notify object];
    BrandDetailViewController * Controller = [[BrandDetailViewController alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) Object:dic];
    [self.navigationController pushViewController:Controller animated:YES];
    [Controller release];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)dealloc
{
    [super dealloc];
}

@end
